<html>
<head>
 <!--
    CPAINT (Cross-Platform Asynchronous INterface Toolkit) - Version 2

    http://sf.net/projects/cpaint
    
    released under the terms of the GPL
    see http://www.fsf.org/licensing/licenses/gpl.txt for details

    authors:  Paul Sullivan <wiley14@gmail.com>, Dominique Stender <dstender@st-webdevelopment.de>
    Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
  //-->
	<title>cpaint2 persistence test</title>
	<script type="text/javascript" src="../../cpaint2.inc.compressed.js"></script>
	<script type="text/javascript">
	<!--
		var cp    = new cpaint();
    
    cp.set_response_type('text');
    cp.set_persistent_connection(true);
    cp.set_debug(0);
	
    function start() {
      document.getElementById('response').innerHTML = '';
      persist(1);
      
      return false;
    }
    
		function persist(num) {
      
			cp.call('persistence.php', 'reply', response, num);
      
      if (num < 20) {
        window.setTimeout('persist(' + (num + 1) + ')', document.getElementById('delay').value * num);
      }
		}

		function response(result) {
			document.getElementById('response').innerHTML = result + '<br />'
                                                    + document.getElementById('response').innerHTML;
		}
	//-->
	</script>
</head>
<body>
	This script tests the usage of a persistent connection in CPAINT2.<br />
  <br />
  On the click of the button the JavaScript within this script will start to iteratively call cpaint
  for a total of twenty times. Between the first and the second call 10 miliseconds will be waited.
  The time between succeeding calls is doubled every time.<br />
  <br />
  In the end you should see the numbers 20 down to 1 on the screen. If that's the case it means that
  CPAINT did successfully perform 20 requests with a single connection. If however some numbers are missing
  this means that the request before the number missing did not finish in time.<br />
  <br />
  CPAINT takes care of this issue my dropping the following requests until the last one has finished.
  <strong>Remember</strong> that this dropping of requests is only an issue if you're using a persistent
  connection, which is not the default. CPAINT is perfectly capable of handling concurrent connections,
  see the concurrency test for that.<br />
	<br />
	<form action="#" onSubmit="return start()">
    <input type="text" id="delay" value="10" /> miliseconds delay<br />
		<input type="submit" value="start persistence test" />
	</form>
	<div id="response"></div>
</body>
</html>
